package com.kuqi.ViewComponent.SlideShow;

import android.view.View;

import androidx.viewpager.widget.ViewPager;

import com.kuqi.R;

import java.util.List;

/**
 * 轮播图监听器
 */
public class HomePageADChangeListener implements ViewPager.OnPageChangeListener {

    // 轮播图显示中的点对象
    private List<View> dots;

    public HomePageADChangeListener(List<View> dots) {
        this.dots = dots;
    }

    // 记录上一次位置
    private int oldPosition = 0;

    @Override
    public void onPageScrollStateChanged(int arg0) {

    }

    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2) {

    }

    @Override
    public void onPageSelected(int position) {
        dots.get(oldPosition).setBackgroundResource(R.drawable.dot_normal);
        dots.get(position).setBackgroundResource(R.drawable.dot_focused);
        oldPosition = position;
    }
}
